// ---------------------------------------------------------- Ajax Table --------------------------------------------------------------
var AjaxTable = {Version:"1.0"};
// ---------------------------------------------------------- Base --------------------------------------------------------------
AjaxTable.Base = function() {
};
AjaxTable.Base.prototype.send = function(action, callBack, stringPars, otherPars) {
	var id = "_" + otherPars.get("id");
	new Insertion.Bottom(id, this.getWaitingString());
	try {
		var sendRequest = new Ajax.SaturnRequest(
		action,{
		     method : "post",
		     parameters : stringPars,
		     onComplete : callBack,
		     args : otherPars
		});
	} catch(error) {
		alert("[ SYSTEM ERROR : ACTION IS EXIT ,ROW ----------> 11 ]" + error.message);
	}
};
AjaxTable.Base.prototype.getWaitingString = function() {
	return "<div style=\"border:red;left:20%;top: 40%;position:absolute;background-color:white;height=17\">&nbsp;&nbsp;<img height=17 src=\"/server-main/images/loading.gif\"></img>&nbsp;&nbsp;<font size=3 >正在请求,请稍等 ... ...</font>&nbsp;&nbsp;</div>";
};
// ---------------------------------------------------------- Data Pool --------------------------------------------------------------
AjaxTable.DataPool = function(docRoot, collectionPars) {
	this.data = new HashMap();
	this.showId = collectionPars.get("id");
	try {
		this.docRoot = docRoot.documentElement;
		this.setData( this.docRoot);
	} catch( error) {
		alert("[SYSTEM ERROR : row 23, docRoot have not context! ]");
	}
	this.count;
};
AjaxTable.DataPool.prototype.praseXML = function() {
	this.setCount( this.docRoot.getElementsByTagName("value"));
	this.setData( this.docRoot.getElementsByTagName("list"));
}; 
AjaxTable.DataPool.prototype.setCount = function( countSet) {
	var countKey = this.showId + "_count";
	for( var i = 0; i < countSet.length; i++ ) {    
    	if( countSet[i].getAttribute("key") == countKey) {
    		this.count = countSet[i].firstChild.nodeValue;
    	}
    }
}; 
AjaxTable.DataPool.prototype.setData = function(dataDoc) {
	function getUtf8Code(value) {
		value = value.replace(/__lt__/g, ">");
		value = value.replace(/__le__/g, "<");
		return value;
	};
	function getRowData(map) {
		var dataObject = new HashMap();
        var data = map.getElementsByTagName("value");
        for(var k = 0; k < data.length; k++ ){ 
            var key = data[k].getAttribute("key");
            var value = "";
            if(data[k].firstChild ) {
                value = getUtf8Code(data[k].firstChild.nodeValue);
            }
            dataObject.put(key, value);
        }
        return dataObject;
	};
	function getAllDataSet(dataDoc) {
		var dataSet = new Array();
	    var map = dataDoc.getElementsByTagName( "map");
	    for( var i = 0; i < map.length; i++ ){
	        dataSet.push(getRowData(map[i]));
	    }
		return dataSet;
	};

	try { 
    	this.data.put(this.showId, getAllDataSet( dataDoc));
    } catch (error) {
    	alert("[SYSTEM ERROR : 解析数据错误! ]");
    }
};
AjaxTable.DataPool.prototype.getCount = function() {
	return this.count;
}; 
AjaxTable.DataPool.prototype.getData = function() {
	return this.data.get(this.showId);
}; 
// ---------------------------------------------------------- Helper --------------------------------------------------------------
AjaxTable.Helper = function() {
	this.data = new Array();
	this.addDatas = new Array();
};
AjaxTable.Helper.prototype.getPrintString = function(data, collectionPars) {
	var stringbuffer = "";
	if(data.length > 0) {
		var logicParmeters = collectionPars.get("logicParmeters");
		var id = collectionPars.get("id");
		if( logicParmeters.get("isCheck")) {
			stringbuffer = "<form name=\"" + collectionPars.get("id") + "Form\">";
		}
		for(var i = 0; i < data.length; i++) {
			stringbuffer += this.rowHeadCode( data[i], i, logicParmeters, collectionPars);
			
			if(logicParmeters.get("isCheck")) {
	   			stringbuffer += "<td><input type=\"checkbox\" name=\"" + id + "Check\" value=\"" + i + "\"></td>";
	       	}
	       	for(var j = 0; j < logicParmeters.get("show").length - 1; j++) {
	       		stringbuffer += this.dataCode(data[i].get(logicParmeters.get("show")[j]), logicParmeters, logicParmeters.get("show")[j], i, collectionPars, data[i]);
	       	}
	       	stringbuffer += " </tr>";
		}
		if(logicParmeters.get("isCheck")) {
			stringbuffer += " </form>";
		}
	} else {
		//alert("");
		new Insertion.Bottom("_" + collectionPars.get("id"), this.getNotDataString());
	}
	return stringbuffer;
	
};
AjaxTable.Helper.prototype.getNotDataString = function() {
    return "";//"<div style=\"border:red;left:10%;top: 40%;position:absolute;background-color:white;height=17\">&nbsp;&nbsp;<img height=1 src=\"/server-main/images/loading.gif\"></img>&nbsp;&nbsp;<font size=3 >没有数据 ... ...</font>&nbsp;&nbsp;</div>";
};
AjaxTable.Helper.prototype.rowHeadCode = function(data, index, logicParmeters, collectionPars) {
	var stringbuffer = "<tr ";
	stringbuffer += this.initRowEventOfTable(index, logicParmeters, collectionPars);
    stringbuffer += "id=\"" + index + "\" ><td class=\"saturn-table-td\" width=\"15\"></td>";
    return stringbuffer;
};
AjaxTable.Helper.prototype.initRowEventOfTable = function(index, logicParmeters, collectionPars) {
	var stringbuffer = "";
	var id = collectionPars.get("id");
	var rowDblclickFunction = logicParmeters.get("rowDblclickFunction");
	var rowClickFunction = logicParmeters.get("rowClickFunction");
	if( rowDblclickFunction!= ""){
   		stringbuffer += "ondblclick=\"" + rowDblclickFunction + "\" ";
   	}
   	stringbuffer += "onclick=\"eventRow(" + index + ",'" + id + "')"
   	if( rowClickFunction!= "") {
   		stringbuffer += ";" + rowClickFunction + "\"";
   	} else {
   		stringbuffer += "\"";
   	}
    return stringbuffer;
};
AjaxTable.Helper.prototype.dataCode = function(data, logicParmeters, field, index, collectionPars, dataSet) {
	var stringbuffer = "";
	
	stringbuffer += "<td class=\"saturn-table-td\" " + this.getColWidthCode(logicParmeters, field) + this.getColEventCode(logicParmeters, field, index, collectionPars) + " >";
	stringbuffer += this.getShowDataCode(data, logicParmeters, field, dataSet) + " </td>";
	return stringbuffer;
};
AjaxTable.Helper.prototype.getColWidthCode = function(logicParmeters, field) {
	var stringbuffer = "";
	try {
		var colWidth = logicParmeters.get("colWidth");
		if(colWidth){
	    	stringbuffer += " width=\"" + colWidth.get(field) + "\"";
	    }
    } catch( error) {
    	alert(error.message);
    }
    return stringbuffer;
};
AjaxTable.Helper.prototype.getColEventCode = function(logicParmeters, field, index, collectionPars) {
	var stringbuffer = "";
	
	var id = collectionPars.get("id");
	try {
		if(logicParmeters.get("colClick").get(field)){
	        stringbuffer += "onclick=\"eventRow(" + index + ",'" + id + "');" + logicParmeters.get("colClick").get(field) + "\" ";
	    }
	    if(logicParmeters.get("colDblclick").get(field)){
	        stringbuffer += "ondblclick=\"" + logicParmeters.get("colDblclick").get(field) + "\" ";
	    }
    } catch( error) {
    	alert(error.message);
    }
    return stringbuffer;
};
AjaxTable.Helper.prototype.getShowDataCode = function(data, logicParmeters, field, dataSet) {
	var stringbuffer = ""; 
	if( data && data != "") {
		stringbuffer += this.getFullData(data, logicParmeters, field, dataSet);
	} else {
		stringbuffer += "";
	}
	return stringbuffer;
};
AjaxTable.Helper.prototype.getFullData = function(data, logicParmeters, field, dataSet) {
	var stringbuffer = "";
	if(logicParmeters.get("colLinkUri").get( field)) {
		stringbuffer = this.getLinkCode(this.getUri( logicParmeters, field, dataSet), this.getName( data, logicParmeters, field, dataSet), logicParmeters, field) ;
	} else {
		stringbuffer = data; 
	}
	return stringbuffer;
};
AjaxTable.Helper.prototype.getLinkCode = function(uri, name, logicParmeters, field) {
	var stringbuffer = "";
	if(logicParmeters.get("collinktype").get(field) == "open"){
		stringbuffer += "<a target=\"_blank \" href=\"" + uri + "\"> " + name + " </a> " ;
	} else {
		stringbuffer += "<a href=\"" + uri + "\"> " + name + " </a> " ;
	}
	return stringbuffer;
};
AjaxTable.Helper.prototype.getUri = function(logicParmeters, field, dataSet) {
	var stringbuffer = "";
	stringbuffer += this.getRealUri(logicParmeters.get("colLinkUri").get(field), dataSet);
	return stringbuffer;
};
AjaxTable.Helper.prototype.getName = function(data, logicParmeters, field, dataSet) {
	var stringbuffer = "";
	if( logicParmeters.get("colLinkName").get(field)) {
		stringbuffer += logicParmeters.get("colLinkName").get( field);
	} else {
		stringbuffer += data;
	}
	return stringbuffer;
};
AjaxTable.Helper.prototype.getRealUri = function(srcUri, dataSet){
    srcUri = srcUri.toString();
	var stringbuffer = "";
	if( srcUri.indexOf("#") != -1) {
		var size = srcUri.match(/\#/gi).length;
		for( var i = 0; i < size; i++) {
			var number = srcUri.indexOf("#");
			var number_last = srcUri.lastIndexOf("#");
			if(i % 2 != 0) {
	    		stringbuffer += this.getValue(dataSet, srcUri.substring(0, number));
			} else {
	    		stringbuffer += srcUri.substring(0, number); 
			}
			srcUri = srcUri.substring(number + 1, number_last + 1);
		}
	}else{
		stringbuffer = srcUri;
	}
	return stringbuffer;
};
AjaxTable.Helper.prototype.getValue = function(dataSet, key){
	if(dataSet.get(key) == null){
		try {
			return document.getElementsByName(key)[0].value ;
		} catch(error) {
			alert("[ SYSTEM ERROR : 表格超链接在页面上取不到值 ]");
		}
	}
	return dataSet.get(key);
};
AjaxTable.Helper.prototype.cleanAllData = function( id) {
	$( id).innerText = "";
};
AjaxTable.Helper.prototype.initPaginationCode = function(collectionPars) {
	if(collectionPars.get("isPagination")) {
		var id = collectionPars.get("id");
		var count = 0 ;
		if(collectionPars.get("count")) {
			count = collectionPars.get("count");
		}
		var startIndex = collectionPars.get("startIndex");
		var endIndex = collectionPars.get("endIndex");
		var perCount = collectionPars.get("perCount");
		var page = 0 ;
		if(collectionPars.get("page")) {
			page = collectionPars.get("page");
		}
		
		page <= 1 ? $(id + "cPage").disabled = true : $(id + "cPage").disabled = false;
		page <= 1 ? $(id + "firstPage").disabled = true : $(id + "firstPage").disabled = false;
		$( id + "nowPage").innerHTML = page;
		if( count != null && count != ""){
			$( id + "Count").innerHTML= "共" + count + "条";
		}
	}
};
AjaxTable.Helper.prototype.getXmlDoc = function(docRoot, collectionPars) {
	if( typeof(docRoot) == "string") {
		docRoot = docRoot.replace(/[\r\n]/g,"");
		eval(" var creatXML = " + collectionPars.get("creatXML") + "; docRoot = creatXML('" + docRoot + "'); ");
	}
	return docRoot;
};
AjaxTable.Helper.prototype.showData = function(docRoot, collectionPars) {
	docRoot = this.getXmlDoc(docRoot, collectionPars);
	var id = "_" + collectionPars.get("id");
	this.cleanAllData(id);
	var datapool = new AjaxTable.DataPool(docRoot, collectionPars);
	this.data = datapool.getData();
	new Insertion.Bottom(id, this.getPrintString(datapool.getData(), collectionPars));
	this.initPaginationCode( collectionPars);
	eventRow( 0, collectionPars.get("id"));
};
AjaxTable.Helper.prototype.showCustemData = function(data, collectionPars) {
	var id = "_" + collectionPars.get("id");
	this.cleanAllData(id);
	new Insertion.Bottom(id, this.getPrintString(data, collectionPars));
	this.initPaginationCode( collectionPars);
	eventRow(clickNumber.get(collectionPars.get("id")), collectionPars.get("id"));
};
AjaxTable.Helper.prototype.getData = function() {
	return this.data ; 
};
AjaxTable.Helper.prototype.updateDatas = function(index, mapData) {
	this.data[index] =  mapData ; 
};
AjaxTable.Helper.prototype.getAddDatas = function() {
	return this.addDatas ; 
};
AjaxTable.Helper.prototype.setAddDataSet = function(mapdata) {
	return this.addDatas.push(mapdata) ; 
};
AjaxTable.Helper.prototype.addXMLDatas = function(docRoot, collectionPars) {
	docRoot = this.getXmlDoc(docRoot, collectionPars);
	var datapool = new AjaxTable.DataPool(docRoot, collectionPars);
	var data = datapool.getData() ;
	this.addDatas.length = 0 ;
	for( var i = 0; i < data.length; i++ ) {
		this.data.push(data[i]) ;
		this.setAddDataSet(data[i]) ;
	}
};
AjaxTable.Helper.prototype.updateXMLDatas = function(docRoot, collectionPars, index) {
	docRoot = this.getXmlDoc(docRoot, collectionPars);
	var datapool = new AjaxTable.DataPool(docRoot, collectionPars);
	var data = datapool.getData() ;
	this.data[index] = data[0];
};
AjaxTable.Helper.prototype.praseXMLOfForm = function(docRoot) {
	var dataObject = new HashMap();
	var data = docRoot.getElementsByTagName("value");
	for(var i = 0; i < data.length; i++ ){ 
	    var key = data[i].getAttribute("key");
	    var value = data[i].firstChild.nodeValue;
	    dataObject.put(key, value);
    }
	return dataObject ;
};
AjaxTable.Helper.prototype.addDatas = function(mapData) {
	this.data.push(mapData) ; 
};
AjaxTable.Helper.prototype.removeData = function(index) {
	this.data.remove(index) ; 
};
// ---------------------------------------------------------- Component --------------------------------------------------------------
AjaxTable.AjaxTableComponent = function(id) {
	this.id = id ;
	this.page = 0 ;
	this.count = 0 ;
	this.action = "" ;
	this.perCount = 8 ; 
	this.startIndex = 0 ;
	this.endIndex = this.startIndex + this.perCount ;
	this.helper = new AjaxTable.Helper() ;
	this.logicParmeters = new HashMap() ;
	this.collectionPars = new HashMap() ;
	this.updateDatas = new Array() ;
	this.allUpdateDatas = new Array() ;
	this.addDatas = new Array() ;
	this.addAllDatas = new Array() ;
	this.removeDatas = new Array() ;
	this.allRemoveDatas = new Array() ;
	this.checkedNumbers = new Array() ;
	this.fields = new Array();
};
AjaxTable.AjaxTableComponent.prototype = new AjaxTable.Base();
AjaxTable.AjaxTableComponent.prototype.initParameters = function(initHiddenField,initAllField,initDblclickField,initDblclickFunction,initClickField,initClickFunction,initLinkField,initLinkName,initLinkUrl,initRowDblclick,initRowClick,initHeadDisplay,initColDisplay,initColWidth,initNotLink,initPagination,isCheck) {
	this.logicParmeters.put("all", initHiddenField.split("/"));
	this.logicParmeters.put("show", initAllField.split("/"));

	var coldblclick = new HashMap();
	for( var i = 0; i < initDblclickField.split("/").length - 1; i++){
		coldblclick.put(initDblclickField.split("/")[i], initDblclickFunction.split("/")[i]);
	}
	this.logicParmeters.put("colDblclick", coldblclick);
	
	var colclick = new HashMap();
	for(var i = 0; i < initClickField.split("/").length - 1; i++){
		colclick.put(initClickField.split("/")[i], initClickField.split("/")[i]);
	}
	this.logicParmeters.put("colClick", colclick);
	
	var collinkuri = new HashMap();
	var collinkname = new HashMap();
	var collinktype = new HashMap();
	for(var i = 0; i < initLinkField.split("/").length - 1; i++) {
		var open = initLinkUrl.split("%")[i].split("@")[0] ;
		var uris = initLinkUrl.split("%")[i].split("@")[1].split(",") ;
		var field = initLinkField.split("/")[i] ;
		var names = initLinkName.split("/")[i].split(",") ;
		collinktype.put(field, open) ;
		collinkuri.put(field, uris) ;
		collinkname.put(field, names) ;
	}
	this.logicParmeters.put("colLinkUri", collinkuri);
	this.logicParmeters.put("colLinkName", collinkname);
	this.logicParmeters.put("collinktype", collinktype);
	
	this.logicParmeters.put("rowDblclickFunction", initRowDblclick);
	this.logicParmeters.put("rowClickFunction", initRowClick);
	this.logicParmeters.put("tableNotLink", initNotLink);
	this.logicParmeters.put("count", 0);
    this.logicParmeters.put("isCheck", isCheck);
    this.logicParmeters.put("isPagination", initPagination);
    this.logicParmeters.put("isHeadDisplay", initHeadDisplay);
    
    if( initColDisplay) {
    	this.logicParmeters.put("colDisplay", initColDisplay.split("/"));
    }else{
    	this.logicParmeters.put("colDisplay", "");
    }
    
    var widthSet = new HashMap();
    for(var i = 0; i < initColWidth.split("/").length; i++) {
    	widthSet.put( initColWidth.split("/")[i].split(":")[0], initColWidth.split("/")[i].split(":")[1]);
    }
    if(initColWidth != "") {
    	this.logicParmeters.put("colWidth", widthSet) ;
    }
	this.initCollectionPar("id", this.id) ;
};
AjaxTable.AjaxTableComponent.prototype.initSendParemeters = function(startIndex, page, count) {
	this.startIndex = startIndex ; 
	this.endIndex = this.startIndex + this.perCount ;
	this.page = page ;
	this.count = count ;
	this.removeDatas.length = 0 ;
	this.addDatas.length = 0 ;
	this.updateDatas.length = 0 ;
	this.helper.initPaginationCode( this.collectionPars) ;
	this.send(this.getActionURI(), this.callBack, this.getPars(), this.getCollectionPars()) ;
};
AjaxTable.AjaxTableComponent.prototype.getCollectionPars = function() {
	this.initCollectionPar( "startIndex", this.startIndex);
	this.initCollectionPar( "endIndex", this.endIndex);
	this.initCollectionPar( "logicParmeters", this.logicParmeters);
	this.initCollectionPar( "page", this.page);
	this.initCollectionPar( "perCount", this.perCount);
	this.initCollectionPar( "count", this.count);
	this.initCollectionPar( "helper", this.helper);
	this.initCollectionPar( "creatXML", this.creatXML);
	return this.collectionPars;
};
AjaxTable.AjaxTableComponent.prototype.initCollectionPar = function(key, value) {
	this.collectionPars.put(key, value);
};
AjaxTable.AjaxTableComponent.prototype.getActionURI = function() {
	return this.action.split("?")[0];
};
AjaxTable.AjaxTableComponent.prototype.getPars = function() {
	var collectionPars = this.getCollectionPars();
	if( this.action.split("?")[1]) {
		return this.action.split("?")[1] + "&startIndex=" + collectionPars.get("startIndex") + "&endIndex=" + collectionPars.get("endIndex") + "&perCount=8";
	} else {
		return "&startIndex=" + collectionPars.get( "startIndex") + "&endIndex=" + collectionPars.get( "endIndex");
	}
};
AjaxTable.AjaxTableComponent.prototype.callBack = function(response, collectionPars) {
	try { 
		var docRoot = response.responseXML;
	} catch(error) {
		alert("[ SYSTEM ERROR : RESPONSE HAVE NOT CONTEXT!  ]" + error.message);
	}
	collectionPars.get("helper").showData(docRoot, collectionPars);
};
AjaxTable.AjaxTableComponent.prototype.getCheckObject = function() {
     eval(" var chk = document." + this.id + "Form." + this.id + "Check ;") ; 
     return chk;
};
AjaxTable.AjaxTableComponent.prototype.initCheckedNumbers = function() {
     var chk = this.getCheckObject() ; 
     this.checkedNumbers.length = 0 ;
     if(chk.length){
	     for(var i = 0; i < chk.length; i++) {   
		     if(chk[i].checked) { 
		     	this.checkedNumbers.push(chk[i].value);
		     } 
	     }
     } else {
     	if(chk.checked) {
     		this.checkedNumbers.push(chk.value);
     	}
     }
};
/** ---------------------------------------------------- 分页 -----------------------------------------------------------------*/
AjaxTable.AjaxTableComponent.prototype.toPage = function(toPage) {
	this.initSendParemeters((toPage - 1) * this.perCount, toPage, count.get(this.id));
};
AjaxTable.AjaxTableComponent.prototype.firstPage = function() {
	this.initSendParemeters(0, 1, count.get(this.id));
};
AjaxTable.AjaxTableComponent.prototype.lastPage = function() {
	this.initSendParemeters((this.page-1) * this.perCount, Math.ceil(this.count / this.perCount), count.get(this.id));
};
AjaxTable.AjaxTableComponent.prototype.nextPage = function(number) {
	((this.page >= 1 && number == 1)||(this.page > 1 && number == -1))? this.page = parseInt(number.toString()) + parseInt(this.page):this.page = 1;
	this.initSendParemeters( ( this.page - 1) * this.perCount, this.page, count.get( this.id));
};
/** ------------------------------------------------------------- 调用接口 ------------------------------------------------------- */
/** 查询数据 */
AjaxTable.AjaxTableComponent.prototype.select = function(action, key, method) {
	count.put(this.id, 0);
	this.action = action;
	if( this.action.indexOf("action") == -1 && this.action.indexOf("jsp") == -1) {
		try { 
			throw new Error(" [ SYSTEM ERROR INFO:表格请求数据的链接不是有效的 ] ");
		} catch(error) {
			alert(error.message);
		}
	} else {
		this.initSendParemeters(0, 1, 0);
	}
};
/** 表格中是否有数据 */
AjaxTable.AjaxTableComponent.prototype.isHaveData = function() {
	if(!this.getDatas()) {
		return false ;
	}
   	if(this.getDatas().length == 0) {
   		return false ;
   	} else {
   		return true ;
   	}
};
/** 转换成xml文档 data是Array型数据*/
AjaxTable.AjaxTableComponent.prototype.changeXML = function(data) {
	var keys = this.logicParmeters.get("all");
	var xmlRoot = "<datas> <list key=\"" + this.id + "\">";
	for(var i = 0; i < data.length; i++) {
		xmlRoot += " <map>";
		for(var j = 0; j < keys.length - 1; j++) {
			xmlRoot += " <value key=\"" + keys[j] + "\">";
			if(data[i].get(keys[j]) != null && data[i].get(keys[j]) != "") {
				 xmlRoot += data[i].get(keys[j]) ;
			} else {
				xmlRoot += ""
			}
			xmlRoot += "</value> "
		}
		xmlRoot += " </map>";
	}
	xmlRoot += " </list> </datas>";
	return this.creatXML(xmlRoot);
};
/** 创建xml文档 */
AjaxTable.AjaxTableComponent.prototype.creatXML = function(string) {
	if(window.DOMParser) {  
        var p = new DOMParser();
	    return p.parseFromString(string, "text/xml");  
	} else if(window.ActiveXObject) {  
	    var doc = new ActiveXObject("Msxml2.DOMDocument");  
		doc.loadXML(string); 
		return doc;  
	} else {
		return false;  
	}
};
/** 取得当前页数据 */
AjaxTable.AjaxTableComponent.prototype.getDatas = function() {
	return this.helper.getData();
};
/** 取得当前行数据 */
AjaxTable.AjaxTableComponent.prototype.getRowDatas = function(index) {
	return this.getDatas()[index] ;
};
/** 显示数据 */
AjaxTable.AjaxTableComponent.prototype.showCustemData = function() {
	this.helper.showCustemData(this.getDatas(), this.collectionPars);
};
/** 取得属性名集合 */
AjaxTable.AjaxTableComponent.prototype.getFields = function() {
	return this.logicParmeters.get("all");
};
/** 更新 */
AjaxTable.AjaxTableComponent.prototype.updateValue = function(key, value) {
	var index = clickNumber.get(this.id) ;
	var oldData = this.getRowDatas(index) ;
	if(value) {
		if(oldData.get(key) != value) {
			oldData.put(key, value) ;
			this.setUpdateDatas(oldData);
			this.setAllUpdateDatas(oldData);
			this.updateDatasOfMap(index, oldData);
			this.showCustemData() ;
		}
	}
};
AjaxTable.AjaxTableComponent.prototype.updateValues = function(xmlRoot) {
	var index = clickNumber.get(this.id) ;
	this.helper.updateXMLDatas(xmlRoot, this.collectionPars, index);
	this.showCustemData() ;
};
AjaxTable.AjaxTableComponent.prototype.updateDatasOfMap = function(index, mapData) {
	this.helper.updateDatas(index, mapData);
};
AjaxTable.AjaxTableComponent.prototype.getUpdateXMLDatas = function() {
	return this.changeXML(this.updateDatas);
};
AjaxTable.AjaxTableComponent.prototype.getUpdateDatas = function() {
	return this.updateDatas;
};
AjaxTable.AjaxTableComponent.prototype.setUpdateDatas = function(updateData) {
	this.updateDatas.push(updateData) ;
};
AjaxTable.AjaxTableComponent.prototype.getAllUpdateXMLDatas = function() {
	return this.changeXML(this.allUpdateDatas);
};
AjaxTable.AjaxTableComponent.prototype.getAllUpdateDatas = function() {
	return this.allUpdateDatas;
};
AjaxTable.AjaxTableComponent.prototype.setAllUpdateDatas = function(updateData) {
	this.allUpdateDatas.push(updateData) ;
};
/** 添加 */
AjaxTable.AjaxTableComponent.prototype.addValue = function(key, value) {
	var addData = new HashMap() ;
	addData.put(key, value);
	this.addMap(addData);
};


AjaxTable.AjaxTableComponent.prototype.addXML = function(xmlDoc) {
	this.helper.addXMLDatas(xmlDoc, this.collectionPars);
	this.initAddDatas();
	this.showCustemData() ;
};
AjaxTable.AjaxTableComponent.prototype.add = function(addData) {
	this.getCollectionPars();
	if(typeof(addData) == "object") {
		this.helper.addXMLDatas(addData.xml, this.collectionPars);
		this.initAddDatas();
	} else {
		this.helper.addXMLDatas(addData, this.collectionPars);
		this.initAddDatas();
	}
	this.showCustemData() ;
};
AjaxTable.AjaxTableComponent.prototype.addMap = function(addData) {
	this.getCollectionPars();
	this.setAddDatas(addData);
	this.setAllAddDatas(addData);
	this.helper.addDatas(addData);
	this.showCustemData() ;
};
AjaxTable.AjaxTableComponent.prototype.initAddDatas = function() {
	var adddatas = this.helper.getAddDatas();
	for(var i = 0; i < adddatas.length; i++) {
		this.setAddDatas(adddatas[i]);
		this.setAllAddDatas(adddatas[i]);
	}
};
AjaxTable.AjaxTableComponent.prototype.addDatas = function(mapData) {
	this.helper.addDatas(mapData);
};
AjaxTable.AjaxTableComponent.prototype.getAddXMLDatas = function() {
	return this.changeXML(this.addDatas);
};
AjaxTable.AjaxTableComponent.prototype.getAddDatas = function() {
	return this.addDatas;
};
AjaxTable.AjaxTableComponent.prototype.setAddDatas = function(addData) {
	this.addDatas.push(addData);
};
AjaxTable.AjaxTableComponent.prototype.getAllAddXMLDatas = function() {
	return this.changeXML(this.addAllDatas);
};
AjaxTable.AjaxTableComponent.prototype.getAllAddDatas = function() {
	return this.addAllDatas;
};
AjaxTable.AjaxTableComponent.prototype.setAllAddDatas = function(addData) {
	this.addAllDatas.push(addData);
};
/** 删除 */
AjaxTable.AjaxTableComponent.prototype.remove = function() {
	this.removeNowData() ;
	this.showCustemData() ;
};
AjaxTable.AjaxTableComponent.prototype.removeDataOfRow = function(index) {
	this.helper.removeData(index);
};
AjaxTable.AjaxTableComponent.prototype.removeChecked = function() {
	this.removeCheckedDatas() ;
	this.showCustemData() ;
};
AjaxTable.AjaxTableComponent.prototype.removeCheckedDatas = function() {
    this.initCheckedNumbers() ;
    var index = 0 ;
	for(var i = this.checkedNumbers.length - 1; i >= 0; i--) {
		index = this.checkedNumbers[i] ;
		this.setRemoveDatas(this.getRowDatas(index)) ;
		this.setAllRemoveDatas(this.getRowDatas(index)) ;
		this.helper.removeData(index);
	}
};
AjaxTable.AjaxTableComponent.prototype.removeNowData = function() {
	if(this.getDatas().length > 0) {
		var index = clickNumber.get(this.id) ;
		var removeData = this.getRowDatas(index) ;
		this.setRemoveDatas(removeData) ;
		this.setAllRemoveDatas(removeData) ;
		this.removeDataOfRow(index) ;
		this.showCustemData() ;
	}
};
AjaxTable.AjaxTableComponent.prototype.getAllRemoveXMLDatas = function() {
	return this.changeXML(this.allRemoveDatas);
};
AjaxTable.AjaxTableComponent.prototype.getAllRemoveDatas = function() {
	return this.allRemoveDatas;
};
AjaxTable.AjaxTableComponent.prototype.getRemoveXMLDatas = function() {
	return this.changeXML(this.removeDatas);
};
AjaxTable.AjaxTableComponent.prototype.getRemoveDatas = function() {
	return this.removeDatas;
};
AjaxTable.AjaxTableComponent.prototype.setRemoveDatas = function(removeData) {
	this.removeDatas.push(removeData);
};
AjaxTable.AjaxTableComponent.prototype.setAllRemoveDatas = function(removeData) {
	this.allRemoveDatas.push(removeData);
};
/** 其他功能 */
AjaxTable.AjaxTableComponent.prototype.checkedAll = function() {
	var chk = this.getCheckObject() ; 
	for(var i = 0; i < chk.length; i++) {
		chk[i].checked = true ;
	}
};
AjaxTable.AjaxTableComponent.prototype.checkedNot = function() {
	var chk = this.getCheckObject() ; 
	for(var i = 0; i < chk.length; i++) {
		chk[i].checked = false ;
	}
};
AjaxTable.AjaxTableComponent.prototype.getValue = function(key) {
	var value = "";
	if( this.getDatas()[clickNumber.get(this.id)].get(key)) { 
		value = this.getDatas()[clickNumber.get(this.id)].get(key) ;
	}
	return value;
};
AjaxTable.AjaxTableComponent.prototype.getAllDataXMLDatas = function() {
	return this.changeXML(this.getDatas());
};
AjaxTable.AjaxTableComponent.prototype.getAllCheckedDataXMLDatas = function() {
	this.initCheckedNumbers() ;
	var checkedDatas = new Array() ;
    var index = 0 ;
	for(var i = 0; i < this.checkedNumbers.length; i++) {
		index = this.checkedNumbers[i] ;
		checkedDatas.push(this.getRowDatas(index)) ;
	}
	return this.changeXML(checkedDatas);
};